import request from "@/api/config";
import { AxiosPromise } from 'axios';
import {PORT} from "@/leadmall/api/config/servicePort";
import { NoteVO, NoteForm, NoteQuery } from '@/leadmall/api/note/types';

/**
 * 查询公告列表
 * @param query
 * @returns {*}
 */

export const listNote = (query?: NoteQuery): AxiosPromise<NoteVO[]> => {
  return request({
    url: PORT +'/leadmall/note/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询公告详细
 * @param id
 */
export const getNote = (id: string | number): AxiosPromise<NoteVO> => {
  return request({
    url: PORT +'/leadmall/note/' + id,
    method: 'get'
  });
};

/**
 * 新增公告
 * @param data
 */
export const addNote = (data: NoteForm) => {
  return request({
    url: PORT +'/leadmall/note',
    method: 'post',
    data: data
  });
};

/**
 * 修改公告
 * @param data
 */
export const updateNote = (data: NoteForm) => {
  return request({
    url: PORT +'/leadmall/note',
    method: 'put',
    data: data
  });
};

/**
 * 删除公告
 * @param id
 */
export const delNote = (id: string | number | Array<string | number>) => {
  return request({
    url: PORT +'/leadmall/note/' + id,
    method: 'delete'
  });
};
